package datastructure.array;

import java.util.Arrays;

/**
 * @author XY
 * @version 1.0
 * @date 2022/3/7 9:09
 * @Description
 */
public class Leet121 {

    //贪心
    public static int maxProfit(int[] prices) {
        int res = 0;
        int min = 10001;
        for (int i = 0; i < prices.length; i++) {
            min = Math.min(prices[i],min);
            res = Math.max(res,(prices[i]-min));
        }
        return res;
    }

    public static void main(String[] args) {
        int[] arr = {7,1,5,3,6,4};
        System.out.println(maxProfit(arr));
    }

}
